"""
camera.py --                                                                                            
                                                                                                                                                                                                        
It sets the camera initial values and its associated light.                                              
                                                                                                                                                                                                            
Date of creation: 2006-11-14                                                                        
                                                                                                                                                                                                
Copyright  Robotics and Automation Group, Pontificia Universidad Javeriana - Cali.                  
    Freddy Naranjo Perez, fnaranjo@puj.edu.co                                                                   
    Antonio Alejandro Matta Gomez amatta@puj.edu.co                                      
    Julian David Colorado, jdcolorado@puj.edu.co                           
    Juan Camilo Acosta Mejia, jcacosta@puj.edu.co                                    
                                                                                                                                                                                                        
See the file "license.terms" for information on usage and redistribution of this file, and for a    
DISCLAIMER OF ALL WARRANTIES.
"""

import vtk
#global variables
FALSE = 0
TRUE = 1
def CameraSettings( ren, VTKwindow):
    """Set up the camera to get a particular view of the scene"""
    
    #Camera's Dolly, Elevation and Pitch angles.
    ren.GetActiveCamera().Dolly(0.32)
    ren.GetActiveCamera().Elevation(25)
    ren.GetActiveCamera().Pitch(10)
    
    #light0: left corner.
    light0 = vtk.vtkLight()
    light0.SetLightTypeToSceneLight()
    light0.PositionalOn()
    light0.SetPosition(-10.0, 10.0, 50.0)
    #light0.SetSpecularColor(1,.8,.5)
    #light0.SetDiffuseColor(.2,.2,.2)
    light0.SetFocalPoint(0,0,0)
    light0.SetIntensity(1.0)
    ren.AddLight(light0)
    
    #light1: right corner.
    light1 = vtk.vtkLight()
    light1.SetLightTypeToCameraLight()
    light1.PositionalOn()
    light1.SetPosition(+10, 10, 50)
    light1.SetSpecularColor(1,.8,.5)
    light1.SetDiffuseColor(.2,.2,.2)
    light1.SetFocalPoint(0,0,0)
    ren.AddLight(light1)
    
def Perspective( ren, flag ):
    """Enables/Disables perspective projection"""
    if flag == TRUE:
        ren.GetActiveCamera().ParallelProjectionOn()
    else:
        ren.GetActiveCamera().ParallelProjectionOff()
        
def StereoOn( ren, VTKwindow, flag ):
    """Enables/disables stereoscopic vision"""
    if flag == TRUE:
        VTKwindow.GetRenderWindow().StereoCapableWindowOn()
        VTKwindow.GetRenderWindow().SetStereoTypeToAnaglyph()
        #VTKwindow.GetRenderWindow().SetAnaglyphColorSaturation(0.6)
        #VTKwindow.GetRenderWindow().SetAnaglyphColorMask  (4,2)
        VTKwindow.GetRenderWindow().StereoRenderOn()
    else:
         VTKwindow.GetRenderWindow().StereoRenderOff()
        
    
    

        
        
            
        
    

    
  
  